<!DOCTYPE html>
<head>
    <meta charset="utf-8">
	<title>{$sys_config['site_name']}</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
	<link rel="stylesheet" href="{$LVB_RES}/js/layui/css/layui.css?t={:rand()}" media="all">
    <link rel="stylesheet" href="{$LVB_RES}/js/login/reset.css?t={:rand()}">
    <link rel="stylesheet" href="{$LVB_RES}/js/login/supersized.css?t={:rand()}">
    <link rel="stylesheet" href="{$LVB_RES}/js/login/style.css?t={:rand()}">
</head>
<body>
    <div class="page-container" id="loginform">
        <h1>登录</h1>
        <form>
			<div>
				<input type="text" id="account" name="account" class="account" placeholder="登录账号" autocomplete="off"/>
			</div>
            <div>
				<input type="password" id="password" name="password" class="password" placeholder="密码"/>
            </div>
            <div class="row cl">
				<input class="input-text size-L captcha" id="txt-captcha" maxlength="5" name="captcha" type="text" placeholder="验证码" style="width:80px;">
				<img style="width: 8em;height: 2.5em; cursor:pointer; vertical-align: middle;" id="captcha" src="{:U('login/captcha')}"> 
				<a title="看不清，换一张" id="kanbuq" href="javascript:">刷新</a>
			</div>
            <button id="btn-submit" type="button">登 录</button>
        </form>
    </div>
	<div class="alert" style="display:none">
		<h2>消息</h2>
		<div class="alert_con">
			<p id="ts"></p>
			<p style="line-height:70px"><a class="btn">确定</a></p>
		</div>
	</div>
	<script src="{$LVB_RES}/js/datatables/js/jquery-1.12.4.js?t={:rand()}" type="text/javascript"></script>
	<!--<script src="{$LVB_RES}/js/login/supersized.3.2.7.min.js?t={:rand()}"></script>-->
	<!--<script src="{$LVB_RES}/js/login/supersized-init.js??t={:rand()}"></script>-->
	<script type="text/javascript" src="{$LVB_RES}/js/layui/layui.js"></script>
	<script>
		layui.use(['layer'], function() {
			$(function(){
                document.onkeydown=function(event){
                    e = event ? event :(window.event ? window.event : null);
                    if(e.keyCode==13){
                        $("#btn-submit").click();
                    }
                }

                //Ajax 登录
				$("#btn-submit").on("click", function(){
					var name = $.trim($("#account").val());
					var pass = $.trim($("#password").val());
					var code = $.trim($("#txt-captcha").val());
					if(name == ""){ layer.msg("请输入登录账号"); return false;}
					if(pass == ""){ layer.msg("请输入密码"); return false;}
					if(code == ""){ layer.msg("请输入验证码"); return false;}
					$.ajax({
						url:"{:U('Login/login')}",
						type:"post",
						data:{account:name, password:pass, captcha:code},
						dataType:"json",
						success:function(rs){
							layer.msg(rs.message, {time:1000}, function(){
								if(rs.error_code > 0){
									changecaptcha();
								}else{
									window.location.href = rs.url;
									return false;
								}
							});
						}
					});
				});
				$("#captcha").on("click", changecaptcha);
				$("#kanbuq").on("click", changecaptcha);
				$("#loginform").on("keydown",function(e){
					if(e.which == 13){
						$(".btn-success").click();
					}
				});
			})
		});

		function is_hide(){ $(".alert").animate({"top":"-40%"}, 300) }
		function is_show(){ $(".alert").show().animate({"top":"45%"}, 300) }
		function changecaptcha(){
			var randnum = Math.ceil(Math.random() * 1000000);
			var src = "{:U('login/captcha')}" ;
			$("#captcha").attr('src', src);
		}
	</script>
</body>
</html>

